﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Xml.Serialization;
using System.IO;


namespace Mimoza.NetworkPlugin
{
    public class NetworkPluginData : PluginsLayer.PluginDataGeneric<NetworkPluginData>
    {
        bool m_isDHCPActive = true;
        bool m_isGatewayDefined = false;
        IPAddress m_gatewayAddress;

        bool m_isAutoDns = true;
        bool m_isDnsDefined = false;
        IPAddress m_prefferedDns;
        IPAddress m_alternateDns;

        public bool IsDHCPActive
        {
            get { return m_isDHCPActive; }
            set { m_isDHCPActive = value; }
        }

        public bool IsGatewayDefined
        {
            get { return m_isGatewayDefined; }
            set { m_isGatewayDefined = value; }
        }
        
        public string GatewayAddress
        {
            get { return m_gatewayAddress==null?"":m_gatewayAddress.ToString(); }
            set
            {
                try
                {
                    m_gatewayAddress = IPAddress.Parse(value);
                }
                catch { }
            }
        }

        public bool IsAutoDns
        {
            get { return m_isAutoDns; }
            set { m_isAutoDns = value; }
        }

        public bool IsDnsDefined
        {
            get { return m_isDnsDefined; }
            set { m_isDnsDefined = value; }
        }

        public string PrefferedDns
        {
            get { return m_prefferedDns == null ? "" : m_prefferedDns.ToString(); }
            set 
            {
                try
                {
                    m_prefferedDns = IPAddress.Parse(value);
                }
                catch { }
            }
        }

        public string AlternateDns
        {
            get { return m_alternateDns == null ? "" : m_alternateDns.ToString(); }
            set 
            {
                try
                {
                    m_alternateDns = IPAddress.Parse(value);
                } catch { }
            }
        }
    }
}
